local weifu = fk.CreateSkill{
  name = "wk_heg__weifu",
}

Fk:loadTranslationTable{
  ["wk_heg__weifu"] = "威抚",
  [":wk_heg__weifu"] = "①其他角色于你回合内响应你使用的牌后，你令你本回合对其使用牌无距离与次数限制；②当你于回合外造成伤害后，你可以令受伤角色交给你一张牌并回复1点体力。",
  ["@@wk_heg__weifu-turn"] = "威抚",
  ["#wk_heg__weifu-give"] = "威抚：请选择一张牌",
  ["#wk_heg__weifu_targetmod"] = "威抚",
}

weifu:addEffect(fk.Damage, {
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    return player.room.current ~= player and player:hasSkill(weifu.name) and 
     player == target and data.to ~= player and #data.to:getCardIds("he") > 0
  end,
  -- on_cost = function(self, event, target, player, data)
  --   local room = player.room
    
  --   if #cards > 0 then
  --     event:setCostData(self, {cards = cards})
  --     return true
  --   end
  -- end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:askToCards(data.to,{
        min_num = 1,
        max_num = 1,
        include_equip = true,
        skill_name = weifu.name,
        prompt = "#wk_heg__weifu-give",
        cancelable = false,
      })
    -- local card_ids = event:getCostData(self).cards
    -- local cards = Fk:getCardById(card_ids)
    room:obtainCard(player, cards, false, fk.ReasonGive)
    room:recover{
      who = data.to,
      num = 1,
      recoverBy = player,
      skillName = weifu.name
    }
  end,
})
  

local weifu_spec = {
  anim_type = "special",
  events = {fk.Damage, fk.CardUseFinished, fk.CardRespondFinished},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(weifu.name) and target ~= player and player.room.current == player and
       data.responseToEvent and data.responseToEvent.card and data.responseToEvent.from == player
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(target, "@@wk_heg__weifu-turn", 1)
  end,
}

weifu:addEffect(fk.CardUseFinished, weifu_spec)
weifu:addEffect(fk.CardRespondFinished, weifu_spec)

weifu:addEffect("targetmod", {
  bypass_times = function(self, player, skill, scope, card, to)
    return card and player:hasSkill(weifu.name) and to:getMark("@@wk_heg__weifu-turn") > 0
  end,
  bypass_distances =  function(self, player, skill, card, to)
    return card and player:hasSkill(weifu.name) and to:getMark("@@wk_heg__weifu-turn") > 0
  end,
})

return weifu
